import requests


# 定义类接口对象层 封装
class EmpMangerApi(object):
    # 定义方法 添加员工
    def add_emp(self, red_header, red_dody):
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
                             headers=red_header, json=red_dody)
        return resp

    # 定义方法 查询员工
    def query_emp(self, em_id, red_header):
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/" + em_id,
                            headers=red_header)
        return resp
    # 定义方法 修改员工


if __name__ == '__main__':
    # 创建实例
    emp = EmpMangerApi()
    # 准备请求头
    req_header = {"Authorization": "98f80b1f-f936-434f-8321-77da20012290"}
    # 准备请求体
    req_body = {"username": "user87655430",
                "mobile": "13947884780",
                "workNumber": "9527890aa"
                }
    # 用实例调用方法
    resp = emp.add_emp(req_header, req_body)
    print("添加员工", resp.json())
